/***************************************************************************
 *   Copyright (C) 2007 by Anders Nore									 								   *
 *   andenore@start.no   												   												 *
 *                                                                         *
 *   Permission is hereby granted, free of charge, to any person obtaining *
 *   a copy of this software and associated documentation files (the       *
 *   "Software"), to deal in the Software without restriction, including   *
 *   without limitation the rights to use, copy, modify, merge, publish,   *
 *   distribute, sublicense, and/or sell copies of the Software, and to    *
 *   permit persons to whom the Software is furnished to do so, subject to *
 *   the following conditions:                                             *
 *                                                                         *
 *   The above copyright notice and this permission notice shall be        *
 *   included in all copies or substantial portions of the Software.       *
 *                                                                         *
 *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       *
 *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    *
 *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*
 *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *
 *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
 *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
 *   OTHER DEALINGS IN THE SOFTWARE.                                       *
 ***************************************************************************/

#ifndef __EXTRA_H
#define __EXTRA_H

#include "mcastchat.h"
#include "thread.h"
#include <sys/socket.h>

extern int num_joined_groups;		/* Number of currently joined groups */
extern struct sockaddr joined_groups[MAX_GROUP_JOINS];		/* Holds our joined multicast groups */
extern char history[MAX_HISTORY][MAX_LINE];
extern int history_index;
extern mutex_t history_mutex;

/**
* Helper functions for adding/removing a multicastgroup in the global
* joined_groups table. Typically called from Mcast_join/leave function.
*/
int addgroup(struct sockaddr *mcastgroup);	/* add to our global table */
int removegroup(struct sockaddr *mcastgroup);	/* remove from our global table */
int ingroup(struct sockaddr *mcastgroup);	/* determine if a multicastaddress is already joined */

/**
* Functions for adding/getting history
*/
void initializeHistory(void);
int addHistory(char *string);
char *getHistory(int index);

#endif /* __EXTRA_H */

